using System.Collections.Generic;
using Microsoft.Xna.Framework;

namespace GameFrameworkLibraly.Helpers.GeometryHelpers
{
    public static partial class Extensions
    {
        public static Vector2 ToVector2(this Point point)
        {
            return new Vector2(point.X, point.Y);
        }

        public static Point ToPoint(this Vector2 vector2)
        {
            return new Point((int) vector2.X, (int) vector2.Y);
        }

        public static Polygon ToPolygon(this Rectangle rectangle)
        {
            List<Point> points = new List<Point>();
            points.Add(new Point(rectangle.Left, rectangle.Top));
            points.Add(new Point(rectangle.Left, rectangle.Bottom));
            points.Add(new Point(rectangle.Right, rectangle.Top));
            points.Add(new Point(rectangle.Right,rectangle.Bottom));
            return new Polygon(points);
        }

        public static bool Intersects2CirclesInscribedInRectangles(this Rectangle rectangle1, Rectangle rectangle2)
        {
            return (rectangle1.Center.ToVector2() - rectangle2.Center.ToVector2()).Length() <
                   rectangle1.Width/2 + rectangle2.Width/2;
        }
        
    }
}
